package com.eascs.afterloan.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.eascs.afterloan.dao.O2oLoanapplyOverdueDao;
import com.eascs.afterloan.entity.O2oLoanapplyOverdue;
import com.eascs.afterloan.form.O2oLoanapplyOverdueForm;
import com.eascs.app.dao.PageResult;

@Service
public class O2oLoanapplyOverdueService {

	@Autowired
	O2oLoanapplyOverdueDao dao;

	public int insert(O2oLoanapplyOverdue entity) {
		return dao.insert(entity);
	}

	public int updateById(O2oLoanapplyOverdue entity) {
		return dao.updateById(entity);
	}

	public O2oLoanapplyOverdue queryById(String id) {
		return dao.getById(O2oLoanapplyOverdue.class, id);
	}

	public O2oLoanapplyOverdue queryByLoanapplyNo(String loanapplyNo) {
		return dao.queryByLoanapplyNo(loanapplyNo);
	}

	public PageResult<Object[]> queryByPage(O2oLoanapplyOverdueForm form) {
		return dao.queryByPage(form);
	}

	public List<Object[]> queryList(String billCode) {
		String sql = "select l.loanapply_no,l.bill_code,olu.user_full_name,opr.province_name,l.operator_name,(SELECT dd.item_name from pub_dditem dd where dd.item_code = l.bank_loan_name and dd.dd_no='10340') as bank_loan_name from o2o_loanapply l LEFT JOIN o2o_platform_regional opr on l.ltd = opr.platform_id right JOIN o2o_bank_loan_data obl on l.bill_code = obl.bill_code"
				+ " LEFT JOIN o2o_loan_user olu on olu.loan_id=l.loan_id and olu.loanapply_no=l.loanapply_no where l.wf_type in('O','HN','YQ','DC') and l.bill_code like ? limit 0,10";
		String param = "%" + billCode + "%";
		return dao.findObjectsList(sql, param);
	}

}
